package com.landary.parameterrplacement.entity;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author 刘欣
 * @createTime 2023/8/1 15:22
 * @description 部门机构
 */
@Data
public class Dept {
    //组织编码
    private String avicDeptCode;
    //组织名称
    private String avicDeptName;
    //父组织编码
    private String avicParentDeptCode;
    //父组织名称
    private String avicParentDeptName;
    //组织状态
    private String avicDeptState;
    //排序号
    private Integer avicSortOrder;

    private String dn;
    //虚拟组织ID
    private String ou;
    //组织级别
    private String avicDeptLevel;
    //组织职责或描述
    private String avicDeptRank;
    //部门类型
    private String avicDeptType;
    //部门简称或代号
    private String avicShowCode;
    //是否有效（自定义，webservice接口推来的数据没有状态）
    private Boolean isAvailable;


    public static List<Dept> mapToUserList(List<Map<String, String>> mapList) {
        List<Dept> deptList = new ArrayList<>();
        for (Map<String, String> map : mapList) {
            Dept dept = new Dept();

            dept.setAvicDeptCode(map.get("avicDeptCode"));
            dept.setAvicDeptName(map.get("avicDeptName"));
            dept.setAvicParentDeptCode(map.get("avicParentDeptCode"));
            dept.setAvicParentDeptName(map.get("avicParentDeptName"));
            dept.setAvicDeptState(map.get("avicDeptState"));
            if (map.get("avicSortOrder") != null) {
                dept.setAvicSortOrder(Integer.parseInt(map.get("avicSortOrder")));
            }
            dept.setDn(map.get("dn"));
            dept.setOu(map.get("ou"));
            dept.setAvicDeptLevel(map.get("avicDeptLevel"));
            dept.setAvicDeptRank(map.get("avicDeptRank"));
            dept.setAvicDeptType(map.get("avicDeptType"));
            dept.setAvicShowCode(map.get("avicShowCode"));
            //对部门中“机构部门”、“测试一级部门”、“测试二级部门1”、“测试二级部门2”，4个测试数据进行过滤
            String avicDeptCode = map.get("avicDeptCode");
            if ("901test".equals(avicDeptCode) || "90101test".equals(avicDeptCode) || "90102test".equals(avicDeptCode)||"0".equals(avicDeptCode)||"部门机构".equals(map.get("avicDeptName"))) {
                continue;
            }
            deptList.add(dept);
        }
        return deptList;
    }
}
